<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>wcsrtombs</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_010_590">&nbsp;</a>NAME</h4><blockquote>
wcsrtombs - convert a wide-character string to a character string
(restartable)
</blockquote><h4><a name = "tag_000_010_591">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="wchar.h.html">wchar.h</a>&gt;

size_t wcsrtombs(char *<i>dst</i>, const wchar_t **<i>src</i>, size_t <i>len</i>, 
    mbstate_t *<i>ps</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_010_592">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>wcsrtombs()</i>
function converts a sequence of wide-characters from the array
indirectly pointed to by
<i>src</i>
into a sequence of corresponding characters, beginning in
the conversion state described by the object pointed to by
<i>ps</i>.
If
<i>dst</i>
is not a null pointer, the converted characters are then stored into
the array pointed to by
<i>dst</i>.
Conversion continues up to and including a terminating null 
wide-character, which is also stored.  Conversion stops earlier in the
following cases:
<ul>
<p>
<li>
When a code is reached that does not correspond to a valid 
character.
<p>
<li>
When the next character would exceed the limit of
<i>len</i>
total bytes to be stored in the array pointed to by
<i>dst</i>
(and
<i>dst</i>
is not a null pointer).
<p>
</ul>
<p>
Each conversion takes place as if by a call to the
<i><a href="wcrtomb.html">wcrtomb()</a></i>
function.
<p>
If
<i>dst</i>
is not a null pointer, the pointer object pointed to by
<i>src</i>
is assigned either a null pointer (if conversion stopped due to
reaching a terminating null wide-character) or the address just 
past the last wide-character converted (if any).  If conversion
stopped due to reaching a terminating null wide-character, the
resulting state described is the initial conversion state.
<p>
If
<i>ps</i>
is a null pointer, the
<i>wcsrtombs()</i>
function uses its own internal
<b>mbstate_t</b>
object, which is initialised at program startup to the initial
conversion state.  Otherwise, the 
<b>mbstate_t</b>
object pointed to by
<i>ps</i>
is used to completely describe the current conversion state of the
associated character sequence.
The implementation will behave as if no function defined in this
specification calls
<i>wcsrtombs()</i>.
<p>
The behaviour of this function is affected by the LC_CTYPE category of
the current locale.  
</blockquote><h4><a name = "tag_000_010_593">&nbsp;</a>RETURN VALUE</h4><blockquote>
If conversion stops because a code is reached that does not correspond
to a valid character, an encoding error occurs.  In this
case, the
<i>wcsrtombs()</i>
function stores the value of the macro EILSEQ in
<i>errno</i>
and returns
<b>(size_t)-1</b>;
the conversion state is undefined.  Otherwise, it returns the number
of bytes in the resulting character sequence, not
including the terminating null (if any).
</blockquote><h4><a name = "tag_000_010_594">&nbsp;</a>ERRORS</h4><blockquote>
The
<i>wcsrtombs()</i>
function may fail if:
<dl compact>

<dt>[EINVAL]<dd>
<i>ps</i>
points to an object that contains an invalid conversion state.

<dt>[EILSEQ]<dd>
A wide-character code does not correspond to a valid character.

</dl>
</blockquote><h4><a name = "tag_000_010_595">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_010_596">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_010_597">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_010_598">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="mbsinit.html">mbsinit()</a></i>,
<i><a href="wcrtomb.html">wcrtomb()</a></i>,
<i><a href="wchar.h.html">&lt;wchar.h&gt;</a></i>.
</blockquote><h4>DERIVATION</h4><blockquote>
Derived from the ISO/IEC 9899:1990/Amendment 1:1995 (E).
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>

